var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("GlobalParams"),
    a = e("AssetsManager"),
    i = e("AudioManager"),
    r = e("ModuleUI"),
    s = e("Game"),
    l = e("RoleSoldierInfo"),
    c = e("UIManager"),
    d = e("ShopViewUI"),
    h = e("AD"),
    _ = e("GetZsViewUI"),
    u = cc._decorator,
    p = u.ccclass,
    m = u.property,
    f = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.hero_ske = null),
                (t.hero_name_label = null),
                (t.hero_info_label = null),
                (t.hero_type_label = null),
                (t.skill_node = []),
                (t.buy_btn_node = null),
                (t.use_btn = null),
                (t.game_hero_index = 0),
                t
            );
        }
        return (
            __extends(t, e),

             (t.prototype.onDisable = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();

            }),

            (t.prototype.initView = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
                Adv_skd.default.instance.showGridAdRightOne();
                Adv_skd.default.instance.showGridAdLeft();
                Adv_skd.default.instance.showBannerAd();
                Adv_skd.default.instance.showInterstitialAd();

                e.prototype.initView.call(this);
            }),
            (t.prototype.OnClick = function (t) {
                switch ((e.prototype.OnClick.call(this, t), t.node.name)) {
                    case "back_btn":
                        this.node.destroy();
                        break;
                    case "buy_btn":
                        this.buyRoleSke();
                }
            }),
            (t.prototype.showHeroInfo = function (e) {
                var t = this;
                this.game_hero_index = e;
                var o = s.default.shop_role_info[e].id;
                this.uiManager.getRoleSkele(o, function (e) {
                    (t.hero_ske.skeletonData = e), t.hero_ske.setAnimation(0, "battle_idle", !0);
                });
                var n = l.default.Role_info[o],
                    i = l.default.Hore_Skill_Info[o];
                (this.hero_name_label.string = n.C_Name),
                    (this.hero_info_label.string = i.hero_info),
                    (this.hero_type_label.string = "【" + (0 == n.C_type ? "近战" : "远程") + "英雄】");
                for (var r = 0; r < this.skill_node.length; r++) {
                    var c = this.skill_node[r];
                    (c.children[0].getComponent(cc.Sprite).spriteFrame = a.default
                        .getInstance()
                        .getHeroSkilIcon(n.C_ID + "0" + (r + 1))),
                        (c.children[1].getComponent(cc.Label).string = 0 == r ? i.one_name : i.two_name),
                        (c.children[3].getComponent(cc.Label).string = 0 == r ? i.one_info : i.two_info),
                        (c.children[4].children[0].getComponent(cc.Label).string =
                            (0 == r ? i.one_time : i.two_time) + "秒");
                }
                this.showRoleSkeBtn();
            }),
            (t.prototype.showRoleSkeBtn = function () {
                var e = s.default.shop_role_info[this.game_hero_index];
                (this.buy_btn_node.children[6].active =
                    -1 != n.GlobalParams.playerSkinInfo.value.have.hero.indexOf(e.id)),
                    (this.buy_btn_node.children[0].active = 0 == e.type && !this.buy_btn_node.children[6].active),
                    (this.buy_btn_node.children[1].active = 1 == e.type && !this.buy_btn_node.children[6].active),
                    (this.buy_btn_node.children[4].active = 2 == e.type && !this.buy_btn_node.children[6].active),
                    (this.buy_btn_node.children[5].active = 3 == e.type && !this.buy_btn_node.children[6].active),
                    (this.buy_btn_node.children[3].active = 4 == e.type && !this.buy_btn_node.children[6].active),
                    (this.buy_btn_node.children[0].children[1].getComponent(cc.Label).string =
                        this.buy_btn_node.children[1].children[1].getComponent(cc.Label).string =
                            "" + e.num * e.discount),
                    (this.buy_btn_node.children[2].active = 1 != e.discount && !this.buy_btn_node.children[6].active),
                    (this.buy_btn_node.children[2].getComponent(cc.Label).string = "" + e.num);
            }),
            (t.prototype.buyRoleSke = function () {
                var e = this,
                    t = s.default.shop_role_info[this.game_hero_index],
                    o = function () {
                        var o = n.GlobalParams.playerSkinInfo.value;
                        (o.use[0] = t.id),
                            o.have.hero.push(t.id),
                            (n.GlobalParams.playerSkinInfo.value = o),
                            cc.find("UIManager").getComponent(c.default).showPopup("ObtainHeroTipView"),
                            e.showRoleSkeBtn();
                    },
                    a = n.GlobalParams.PlayerInfo.value;
                if (this.use_btn.children[0].active) {
                    var r = t.num * t.discount;
                    a.coin >= r
                        ? (cc.find("UIManager").getComponent(c.default).consumeCoinAndZs(0, r), o())
                        : cc
                              .find("UIManager")
                              .getComponent(c.default)
                              .showPopup("ShopViewUI", function (e) {
                                  e.getComponent(d.default).showShopTypeInfo("shop_coin_btn");
                              });
                } else if (this.use_btn.children[1].active) {
                    var l = t.num * t.discount;
                    a.zs >= l
                        ? (cc.find("UIManager").getComponent(c.default).consumeCoinAndZs(1, l), o())
                        : cc
                              .find("UIManager")
                              .getComponent(c.default)
                              .showPopup("GetZsViewUI", function (e) {
                                  e.getComponent(_.default).showPopupInfoView(0);
                              });
                } else
                    this.use_btn.children[3].active
                        ? h.default.getInstance().showVideo(function (e) {
                              i.default.playGameBGM(), e == h.ResultEnum.Success && o();
                          })
                        : this.use_btn.children[4].active
                        ? this.uiManager.showPopup("SigninViewUI")
                        : this.use_btn.children[5].active && this.uiManager.showPopup("LuckyBoxViewUI");
            }),
            __decorate([m(sp.Skeleton)], t.prototype, "hero_ske", void 0),
            __decorate([m(cc.Label)], t.prototype, "hero_name_label", void 0),
            __decorate([m(cc.Label)], t.prototype, "hero_info_label", void 0),
            __decorate([m(cc.Label)], t.prototype, "hero_type_label", void 0),
            __decorate([m(cc.Node)], t.prototype, "skill_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "buy_btn_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "use_btn", void 0),
            __decorate([p], t)
        );
    })(r.default);
o.default = f;
